package com.xhdx.pattern.visitor;

import java.util.Random;
/**
 * test
 *
 */
public class VisitorDemo {

    public static void main(String[] args) {
        for (int i = 0; i < 5;i++) {
            Schoolbag schoolbag = createElement();
            schoolbag.accept(new ConcreteVisitor());
        }
    }
    public static Schoolbag createElement() {
        Random random = new Random();
        if (random.nextInt(100) > 50) {
            return new ChineseBook();
        } else {
            return new EnglishBook();
        }
    }
}
